package com.woniu.darryringmall.front.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniu.darryringmall.front.entity.Order;
import com.woniu.darryringmall.front.entity.OrderItems;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.List;

/**
 * 订单表mapper
 */
public interface OrderMapper extends BaseMapper<Order> {
    @Update("update mall_order set status=#{status} where id=#{id}")
    void update(@Param("id")int id, @Param("status")String status);

    //查找status为3的所有订单信息
    @Select("select * from mall_order where status=3 and userid=#{userid}")
    List<Order> getByStatu3(int userid);

    //查找status为4的所有订单信息
    @Select("select * from mall_order where status=4 and userid=#{userid}")
    List<Order> getByStatu4(int userid);

    //查找status为5的所有订单信息
    @Select("select * from mall_order where status=5 and userid=#{userid}")
    List<Order> getByStatu5(int userid);

    //计算所有已完成订单的总金额（状态码7）
    @Select("select sum(money) from mall_order where status=7 and userid=#{userid}" )
    BigDecimal getMoney(int userid);



}
